Skip to content

Update clients and add product endpoint support - #13

Merged
ahcodedev merged 1 commit into
mainfrom
prices-api-product
Nov 9, 2026
Merged

ahcodedev merged 1 commit into
mainfrom
prices-api-product

Conversation

@ahcodedev

@ahcodedev ahcodedev commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

Implements the first API operation, product (GET /api/product), on both clients, and adds the error handling and test setup the remaining endpoints will build on.

Clients (PriceCharting, AsyncPriceCharting)

  • product(id=None, upc=None, q=None) returns a ProductResponse. It needs exactly one of id, upc, or q. If it gets none, or more than one, it raises ParameterError and sends no request, so a bad call doesn't count against the rate limit.
  • New base_url (default https://www.pricecharting.com) and transport constructor parameters, in the same order as httpx2, so the clients can point at a mock server or use httpx2.MockTransport in tests.

Errors (error.py)

  • PriceChartingError is the base class for all library errors.
  • ParameterError (also a ValueError) is raised for invalid method arguments.
  • APIError is raised for API error responses. It carries message and status_code.

Response parsing (responses.py)

  • New private helper _parse(response, model) raises APIError if the body isn't JSON, the status code isn't 2xx, or the body says status: error. Otherwise it validates the JSON into the given model. It doesn't call raise_for_status(), because that error message would include the token in the URL.

Package exports

  • The clients, errors, request and response models, shared models, and types enums can all be imported from pypricecharting, e.g. from pypricecharting import APIError, ProductResponse.

Docs and metadata

  • docs/index.md has new sections: getting a product, errors, client options (base_url / transport), and imports.
  • New Errors API reference page (docs/api/errors.md).

Tests

  • product tests for both clients run against a mock transport. They cover each lookup parameter, the API error case, and the parameter validation cases.
  • New tests for the transport and base_url constructor parameters, APIError, _parse, and the package exports. tests/test_init.py fails if a public class in models, requests, responses, or types isn't exported.
  • New mock client helpers are in tests/mocks/mock_pricecharting.py.

Type of Change

feature: new endpoint and new public API (errors, constructor parameters, package exports).

Checklist

  • just lint passes
  • just test passes (170 tests, 100% coverage)
  • Tests added or updated for the change
  • Docs updated if needed (README.md, docs/, CLAUDE.md)
  • Release label added

@ahcodedev ahcodedev added the feature New feature (minor version bump) label Nov 9, 2026
@ahcodedev
ahcodedev merged commit 2dfe41a into main Nov 9, 2026
11 checks passed
@ahcodedev
ahcodedev deleted the prices-api-product branch November 9, 2026 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature (minor version bump)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant